package com.ruoyi.Api;


import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.countrybus.domain.SysVehicle;
import com.ruoyi.project.countrybus.service.ISysVehicleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("车辆API")
@RestController
@RequestMapping("/api/vehicle")
public class VehicleApi extends BaseController
{
    @Autowired
    private ISysVehicleService sysVehicleService;


    @ApiOperation("查询车辆信息列表")
    @GetMapping("/list")
    public TableDataInfo list(SysVehicle sysVehicle)
    {
        startPage();
        List<SysVehicle> list = sysVehicleService.selectSysVehicleList(sysVehicle);
        return getDataTable(list);
    }

    /**
     * 获取车辆信息详细信息
     */
    @ApiOperation("通过ID获取车辆详细信息")
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return AjaxResult.success(sysVehicleService.selectSysVehicleByVehicleId(vehicleId));
    }

    /**
     * 新增车辆信息
     */
    @ApiOperation("新增车辆信息")
    @PostMapping
    public AjaxResult add(@RequestBody SysVehicle sysVehicle)
    {
        return toAjax(sysVehicleService.insertSysVehicle(sysVehicle));
    }

    /**
     * 修改车辆信息
     */
    @ApiOperation("修改车辆信息")
    @PutMapping
    public AjaxResult edit(@RequestBody SysVehicle sysVehicle)
    {
        return toAjax(sysVehicleService.updateSysVehicle(sysVehicle));
    }

    /**
     * 删除车辆信息
     */
    @ApiOperation("删除车辆信息")
    @DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(sysVehicleService.deleteSysVehicleByVehicleIds(vehicleIds));
    }

}
